<?php
// +----------------------------------------------------------------------
// | Description: 系统用户
// +----------------------------------------------------------------------
// | Author: linchuangbin <linchuangbin@honraytech.com>
// +----------------------------------------------------------------------

namespace app\admin\controller;



class BidMember extends ApiCommon
{

    public function index()
    {
        $biddingModel = model('BidMember');
        $param = $this->param;
        $data = $biddingModel->getDataList($param);
        return resultArray(['data' => $data]);
    }

    public function save()
    {
        $Model = model('BidMember');
        $param = $this->param;
        $arr=[];
        $upArr=[];
        foreach ($param as $k=>$v){
            if(!empty($v['id'])){
                $upArr[]=$v;
                continue;
            };
            $arr[]=$v;
        }
        $data = $Model->insertAll($arr);
        foreach ($upArr as $k=>$v){
            $Model->updateDataById($v,$v['id']);
        }
        if (!$data) {
            return resultArray(['error' => $Model->getError()]);
        }
        return resultArray(['data' => '添加成功']);
    }

    public function update()
    {
        $Model = model('BidMember');
        $param = $this->param;
        $data = $Model->updateDataById($param, $param['id']);
        if (!$data) {
            return resultArray(['error' => $Model->getError()]);
        }
        return resultArray(['data' => '编辑成功']);
    }

    public function delete()
    {
        $userModel = model('BidMember');
        $param = $this->param;
        $data = $userModel->delDataById($param['id']);
        if (!$data) {
            return resultArray(['error' => $userModel->getError()]);
        }
        return resultArray(['data' => '删除成功']);
    }

    public function deletes()
    {
        $Model = model('BidMember');
        $param = $this->param;
        $data = $Model->delDatas($param['ids']);
        if (!$data) {
            return resultArray(['error' => $Model->getError()]);
        }
        return resultArray(['data' => '删除成功']);
    }

}
